# _*_ coding: utf-8 _*_
# @Time : 2024-01-22 22:28
# @Author : wf
import openpyxl.cell.cell
from openpyxl import Workbook
from openpyxl.worksheet.worksheet import Worksheet

# 创建workboob
wb = Workbook()
# 创建 sheet页
ws: openpyxl.worksheet.worksheet.Worksheet = wb.active
print(type(ws))

# cell = ws['a2'] = 'test'
cell: openpyxl.cell.cell.Cell = ws.cell(3, 2, 'test')
print(type(cell))
print(cell.value)
print(cell.coordinate)
print(cell.row)
print(cell.column)
print(cell.column_letter)

# 遍历数据-列
print(ws['b'])
print(ws['a:c'])

# 遍历数据-行
print(ws[1])
print(ws[1:4])

# 遍历数据-行列
print(ws['a1:c3'])

# 遍历所有数据
# 行
print(ws.iter_rows())
# 列
print(ws.iter_cols())

wb.save('test.xlsx')
